﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AForge.Genetic;

namespace GW2BARG
{
    public class GW2BuildChromosome : ShortArrayChromosome 
    {
        public static short[] maxValueMap;
        static GW2BuildChromosome()
        {
            maxValueMap = new short[112]{/*[0-69] 70 Trait Point Allocations*/ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
                                                                               4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                                                                               4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
                                         /*[70-72] 1st Line Major Trait Picks - may not be usable with points*/ 12, 11, 10, /*elementalist hardcoded, this will change */
                                         /*[73-75] 2nd Line Major Trait Picks - may not be usable with points*/ 11, 10, 9, /*elementalist hardcoded, this will change */
                                         /*[76-78] 3rd Line Major Trait Picks - may not be usable with points*/ 10, 9, 8, /*elementalist hardcoded, this will change */
                                         /*[79-81] 4th Line Major Trait Picks - may not be usable with points*/ 11, 10, 9, /*elementalist hardcoded, this will change */
                                         /*[82-84] 5th Line Major Trait Picks - may not be usable with points*/ 10, 9, 8, /*elementalist hardcoded, this will change */
                                         /*[85] Healing Skill*/ 2, /*3 choices, elementalist hardcoded, this will change */
                                         /*[86-88] Utility Skills*/ 19, 18, 17, /*3 * 20 choices, elementalist hardcoded, this will change */
                                         /*[89] Elite Skill*/ 2, /*3 choices, elementalist hardcoded, this will change */
                                         /*[90] Initial Weapon Loadout*/ 4, /*5 total possible permutations, elementalist hardcoded, this will change */
                                         /*[91] Initial Attunement*/ 4, /*elementalist hardcoded, this will change */
                                         /*[92-111] Sequence of 20 actions*/ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13};
                                         /* 14 possible actions: 0-4 Weapon skills, 5 Healing, 6-8 Utility, 9 Elite, 10-13 Attunement Change*/
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="GW2BuildChromosome"/> class.
        /// </summary>
        /// <remarks>This constructor initializes chromosome setting length to 112 (Which is the Elementalis's array length).</remarks>
        /// 
        public GW2BuildChromosome() : base(112 /* Length. This icky literal will change when other values can be supplied*/) { }

        /// <summary>
        /// Generate random chromosome value.
        /// </summary>
        /// 
        /// <remarks><para>Regenerates chromosome's value using random number generator.</para>
        /// </remarks>
        /// 
        public override void Generate( )
        {
            for ( int i = 0; i < length; i++ )
            {
                // generate next value
                val[i] = (ushort)rand.Next(maxValueMap[i]);
            }
        }

        /// <summary>
        /// Mutation operator.
        /// </summary>
        /// 
        /// <remarks><para>The method performs chromosome's mutation, changing randomly
        /// one of its genes (array elements).</para></remarks>
        /// 
        public override void Mutate()
        {
            // get random index
            int i = rand.Next(length);
            // randomize the gene
            val[i] = (ushort)rand.Next(maxValueMap[i] + 1);
        }
    }

    
}
